class Node:
    def __init__(self,key,value):
        self.key=key
        self.value=value
        self.next=None

class MyHashMap:

    def __init__(self):
        """
        Initialize your data structure here.
        """
        self.length=769
        self.hashmap=[0]*769


    def put(self, key: int, value: int) -> None:
        """
        value will always be non-negative.
        """
        i=key%self.length
        if self.hashmap[i]==0:
            self.hashmap[i]=Node(key,value)
        else:
            t=self.hashmap[i]
            if t.key==key:
                t.value=value
            elif t.value>value:
               self.hashmap[i]= Node(key,value)
               self.hashmap[i].next=t
            else:
                while t.next and t.next.key<key:
                    t=t.next
                if not t.next:
                    t.next=Node(key,value)
                else:
                    if t.next.key==key:
                        t.next.value=value
                    else:
                        temp=t.next
                        t.next=Node(key,value)
                        t.next.next=temp


    def get(self, key: int) -> int:
        """
        Returns the value to which the specified key is mapped, or -1 if this map contains no mapping for the key
        """
        t=self.hashmap[key%self.length]
        if t==0:
            return -1
        else:
            while t and t.key<key:
                t=t.next
            if t is None or t.key!=key:
                return -1
            else:
                return t.value

    def remove(self, key: int) -> None:
        """
        Removes the mapping of the specified value key if this map contains a mapping for the key
        """
        t=self.hashmap[key%self.length]
        if t==0:
            return 
        if t.key==key:
            if t.next:
                self.hashmap[key%self.length]=t.next
            else:
                self.hashmap[key%self.length]=0
            del t
        else:
            while t.next and t.next.key<key:
                t=t.next
            if not t.next:
                return 
            if t.next.key==key:
                t.next=t.next.next
            else:
                return 



# Your MyHashMap object will be instantiated and called as such:
# obj = MyHashMap()
# obj.put(key,value)
# param_2 = obj.get(key)
# obj.remove(key)